<html>
<head><meta charset="utf-8"><title>impl signature mismatch errors PR #67460 · t-compiler/wg-diagnostics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/index.html">t-compiler/wg-diagnostics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html">impl signature mismatch errors PR #67460</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198496763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496763">(May 22 2020 at 21:26)</a>:</h4>
<p>So <span class="user-mention" data-user-id="119031">@Esteban Küber</span></p>



<a name="198496800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496800">(May 22 2020 at 21:26)</a>:</h4>
<p>I think part of why I find the new output confusing is because the <code>expected fn(...)</code> and <code>you might want to borrow this type parameter</code> labels overlap</p>



<a name="198496813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496813">(May 22 2020 at 21:27)</a>:</h4>
<div class="codehilite"><pre><span></span><code>LL |     fn get_relation(&amp;self) -&gt; To;
   |     -----------------------------
   |     |                         |
   |     |                         you might want to borrow this type parameter in the trait to make it match the `impl`
   |     expected `fn(&amp;Article) -&gt; &amp;ProofReader`
</code></pre></div>



<a name="198496863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496863">(May 22 2020 at 21:27)</a>:</h4>
<div class="codehilite"><pre><span></span><code>LL |     fn get_relation(&amp;self) -&gt; To;
   |     --                        --
   |     |                         |
   |     |                         you might want to borrow this type parameter in the trait to make it match the `impl`
   |     expected `fn(&amp;Article) -&gt; &amp;ProofReader`
</code></pre></div>



<a name="198496874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496874">(May 22 2020 at 21:27)</a>:</h4>
<p>I wonder if even that change would help a bit</p>



<a name="198496949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496949">(May 22 2020 at 21:28)</a>:</h4>
<p>I would probably remove this highlight, too</p>
<div class="codehilite"><pre><span></span><code>LL | pub trait HaveRelationship&lt;To&gt; {
   |                            -- this type parameter might not have a lifetime compatible with the `impl`
</code></pre></div>



<a name="198496960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496960">(May 22 2020 at 21:28)</a>:</h4>
<p>because there's really nothing <em>wrong</em> with that type parameter</p>



<a name="198496984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198496984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198496984">(May 22 2020 at 21:28)</a>:</h4>
<p>the problem is more about how the function is declared (and perhaps the value for that type parameter given in the impl)</p>



<a name="198497109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497109">(May 22 2020 at 21:30)</a>:</h4>
<div class="codehilite"><pre><span></span><code>LL |     fn get_relation(&amp;self) -&gt; To;
   |     --                        -- maybe you want `&amp;To` instead?
   |     |
   |     trait contains `fn(&amp;Article) -&gt; &amp;ProofReader`
...
LL |     fn get_relation(&amp;self) -&gt; &amp;ProofReader {
   |     ^^ but impl contains`fn(&amp;Article) -&gt; &amp;ProofReader`
   |
   = note: expected `fn(&amp;Article) -&gt; &amp;ProofReader`
              found `fn(&amp;Article) -&gt; &amp;ProofReader`
   = note: the lifetime requirements from the `trait` could not be satisfied by the `impl`
   = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
</code></pre></div>



<a name="198497130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497130">(May 22 2020 at 21:30)</a>:</h4>
<p>hmm, not great, but I'm trying to mix and match between our two :)</p>



<a name="198497164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497164">(May 22 2020 at 21:30)</a>:</h4>
<p>I guess I have to look at the code to see just how much we've figured out</p>



<a name="198497170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497170">(May 22 2020 at 21:30)</a>:</h4>
<p>How specific are those issues you're seeing?</p>



<a name="198497177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497177">(May 22 2020 at 21:30)</a>:</h4>
<p>Is it always in the <em>return value</em></p>



<a name="198497178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497178">(May 22 2020 at 21:30)</a>:</h4>
<p>if we specialize a bit more we might be able to do</p>



<a name="198497363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497363">(May 22 2020 at 21:33)</a>:</h4>
<p>something where we focus on the return value:</p>
<div class="codehilite"><pre><span></span><code>LL |     fn get_relation(&amp;self) -&gt; To;
   |                               -- trait returns `To` maybe you want `&amp;To` instead?
...
LL |     fn get_relation(&amp;self) -&gt; &amp;ProofReader {
   |                               ^^^^^^^^^^ but impl returns borrowed reference
   |
   = note: expected `fn(&amp;Article) -&gt; &amp;ProofReader`
              found `fn(&amp;Article) -&gt; &amp;ProofReader`
   = note: the lifetime requirements from the `trait` could not be satisfied by the `impl`
   = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
</code></pre></div>


<p>not quite that phrasing. Anyway, if we looked for a case where you:</p>
<ul>
<li>return a reference with a late-bound lifetime</li>
<li>the trait returns a type parameter</li>
</ul>
<p>is that the case you're seeing frequently? It seems like we ought to be able to say something at least <em>somewhat</em> clear</p>



<a name="198497371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497371">(May 22 2020 at 21:33)</a>:</h4>
<p>The reason I pointed at <code>To</code> is because I want to convey that <code>To == &amp;ProofReader</code>, while what you likely want is <code>To == ProofReader</code></p>



<a name="198497387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497387">(May 22 2020 at 21:33)</a>:</h4>
<p>ah right, that's the pattern, that the impl has <code>ProofReader&lt;&amp;Foo&gt;</code></p>



<a name="198497394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497394">(May 22 2020 at 21:33)</a>:</h4>
<p>but that is only a single possible solution</p>



<a name="198497412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497412">(May 22 2020 at 21:33)</a>:</h4>
<p>yeah, it's hard to know what people want of course,</p>



<a name="198497462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497462">(May 22 2020 at 21:34)</a>:</h4>
<p>I <em>suspect</em> that they want <code>ProofReader&lt;Foo&gt;</code></p>



<a name="198497466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497466">(May 22 2020 at 21:34)</a>:</h4>
<p>and the <code>&amp;</code> in the trait/impl methods</p>



<a name="198497467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497467">(May 22 2020 at 21:34)</a>:</h4>
<p>but hard to know</p>



<a name="198497500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497500">(May 22 2020 at 21:35)</a>:</h4>
<p>This is a recent report: <a href="https://github.com/rust-lang/rust/issues/72106">https://github.com/rust-lang/rust/issues/72106</a></p>



<a name="198497508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497508">(May 22 2020 at 21:35)</a>:</h4>
<p>so, apart from the challenge of implementing...</p>



<a name="198497515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497515">(May 22 2020 at 21:35)</a>:</h4>
<p>do you have a list of the issues</p>



<a name="198497525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497525">(May 22 2020 at 21:35)</a>:</h4>
<p>maybe skimming them might help to understand what users are wanting</p>



<a name="198497603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497603">(May 22 2020 at 21:36)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span>: <span class="nb">Sized</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">value</span>: <span class="kp">&amp;</span><span class="kt">str</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="kt">str</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">value</span>: <span class="kp">&amp;</span><span class="kt">str</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="kt">str</span> <span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">value</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>Basically when implementing something for <code>&amp;T</code> on a trait that originally was meant to be impld in <code>T</code></p>



<a name="198497609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497609">(May 22 2020 at 21:36)</a>:</h4>
<p>Yeah.</p>



<a name="198497619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497619">(May 22 2020 at 21:36)</a>:</h4>
<p>I can't quite tell what the user wanted in this case</p>



<a name="198497673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497673">(May 22 2020 at 21:37)</a>:</h4>
<p>or <a href="https://github.com/rust-lang/rust/issues/66406">https://github.com/rust-lang/rust/issues/66406</a> :)</p>



<a name="198497694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497694">(May 22 2020 at 21:37)</a>:</h4>
<p>I guess that in <a href="https://github.com/rust-lang/rust/issues/72106">#72106</a></p>



<a name="198497695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497695">(May 22 2020 at 21:37)</a>:</h4>
<p>they probably wanted</p>



<a name="198497750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497750">(May 22 2020 at 21:38)</a>:</h4>
<div class="codehilite"><pre><span></span><code>impl&lt;&#39;a&gt; Foo for &amp;&#39;a str {
    fn foo(value: &amp;str) -&gt; &amp;&#39;a str {
    }
}
</code></pre></div>


<p>but of course that code can never work</p>



<a name="198497765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497765">(May 22 2020 at 21:38)</a>:</h4>
<p>in other words, there isn't really a correct fix except for "use <code>String</code>" :)</p>



<a name="198497792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497792">(May 22 2020 at 21:38)</a>:</h4>
<p>well ok or maybe </p>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">FromSql</span><span class="o">&lt;</span><span class="na">&#39;input</span><span class="o">&gt;</span>: <span class="nb">Sized</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">column_result</span><span class="p">(</span><span class="n">value</span>: <span class="nc">ValueRef</span><span class="o">&lt;</span><span class="na">&#39;input</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">FromSqlResult</span><span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="198497838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497838">(May 22 2020 at 21:39)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="na">&#39;input</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromSql</span><span class="o">&lt;</span><span class="na">&#39;input</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="na">&#39;input</span><span class="w"> </span><span class="kt">str</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">column_result</span><span class="p">(</span><span class="n">value</span>: <span class="nc">ValueRef</span><span class="o">&lt;</span><span class="na">&#39;input</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">FromSqlResult</span><span class="o">&lt;&amp;</span><span class="na">&#39;input</span><span class="w"> </span><span class="kt">str</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">value</span><span class="p">.</span><span class="n">as_str</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="198497846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497846">(May 22 2020 at 21:39)</a>:</h4>
<p>it depends a bit how it's going to be used</p>



<a name="198497860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497860">(May 22 2020 at 21:39)</a>:</h4>
<p>but I <em>suspect</em> that the latter pattern would lead them down a dead-end</p>



<a name="198497880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497880">(May 22 2020 at 21:39)</a>:</h4>
<p>so maybe we cna't really suggest for them how to fix, just try to help them understand the <em>problem</em></p>



<a name="198497895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497895">(May 22 2020 at 21:39)</a>:</h4>
<p>and I think a big part of it is that lifetime elision is triggering at the <em>method</em> level</p>



<a name="198497986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198497986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198497986">(May 22 2020 at 21:40)</a>:</h4>
<p>it's not only elision, but its interaction with the lifetimes received from the trait</p>



<a name="198498033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498033">(May 22 2020 at 21:41)</a>:</h4>
<p>This was one of the WIP outputs <a href="https://user-images.githubusercontent.com/1606434/71327837-80b7b580-24c2-11ea-834f-73e43d1a1116.png">https://user-images.githubusercontent.com/1606434/71327837-80b7b580-24c2-11ea-834f-73e43d1a1116.png</a></p>
<div class="message_inline_image"><a href="https://user-images.githubusercontent.com/1606434/71327837-80b7b580-24c2-11ea-834f-73e43d1a1116.png"><img src="https://user-images.githubusercontent.com/1606434/71327837-80b7b580-24c2-11ea-834f-73e43d1a1116.png"></a></div>



<a name="198498077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498077">(May 22 2020 at 21:41)</a>:</h4>
<p>which worked well _for that specific case_</p>



<a name="198498192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498192">(May 22 2020 at 21:42)</a>:</h4>
<p>for the last case trying to apply the same approach it would look like</p>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span>: <span class="nb">Sized</span> <span class="o">+</span><span class="w"> </span><span class="na">&#39;a</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">value</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="o">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">value</span>: <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="na">&#39;a</span><span class="w"> </span><span class="kt">str</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">value</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="198498235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498235">(May 22 2020 at 21:43)</a>:</h4>
<div class="codehilite"><pre><span></span><code>pub trait FromSql: Sized {
    fn column_result(value: ValueRef&lt;&#39;_&gt;) -&gt; FromSqlResult&lt;Self&gt;;
}

impl FromSql for &amp;str {
                 ---- the trait signature returns data borrowed from here
    fn column_result(value: ValueRef&lt;&#39;_&gt;) -&gt; FromSqlResult&lt;&amp;str&gt; {
                                                           ^ defaults to data borrowed from `value`
        value.as_str()
    }
}
</code></pre></div>



<a name="198498245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498245">(May 22 2020 at 21:43)</a>:</h4>
<p>heh I don't <em>quite</em> know how easy/hard that would be, I'm just noodling  I guess</p>



<a name="198498314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498314">(May 22 2020 at 21:44)</a>:</h4>
<p>with a help being something like</p>
<p>= help: either alter the trait to return borrowed data<br>
= help: or try adding explicit lifetime names</p>



<a name="198498328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498328">(May 22 2020 at 21:44)</a>:</h4>
<p>honestly probably just "try adding explicit lifetime names" is the best advice we can give people</p>



<a name="198498393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498393">(May 22 2020 at 21:45)</a>:</h4>
<p><span aria-label="crab" class="emoji emoji-1f980" role="img" title="crab">:crab:</span>ZWJ<span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span>‍♀️</p>



<a name="198498405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498405">(May 22 2020 at 21:45)</a>:</h4>
<p>...</p>



<a name="198498573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498573">(May 22 2020 at 21:47)</a>:</h4>
<p>Should we keep the "expected/found" format?<br>
If we do, to avoid the issue with overlapping labels I can move the "borrow this" to its own <code>note</code></p>



<a name="198498699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498699">(May 22 2020 at 21:48)</a>:</h4>
<p>it seems like a key part of the confusion</p>



<a name="198498707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498707">(May 22 2020 at 21:48)</a>:</h4>
<p>is also that those two strings are equal</p>



<a name="198498728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498728">(May 22 2020 at 21:48)</a>:</h4>
<p>And we'd need to change "you might want to borrow this type parameter in the trait to make it match the <code>impl</code>" to something closer to "consider borrowing this type parameter"</p>



<a name="198498810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498810">(May 22 2020 at 21:49)</a>:</h4>
<p>I really feel like we want to somehow explain that the signature as written is causing it to borrow data frm one of the arguments</p>



<a name="198498814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498814">(May 22 2020 at 21:49)</a>:</h4>
<p>yep, it's also part of a larger problem of the lifetime names being local to the trait/impl<br>
you can easily swap them by accident and get weird lifetime errors</p>



<a name="198498881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498881">(May 22 2020 at 21:50)</a>:</h4>
<p>though how <em>exactly</em> to word that</p>



<a name="198498891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198498891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198498891">(May 22 2020 at 21:50)</a>:</h4>
<p>it seems like something we ought to be able to detect though</p>



<a name="198499021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198499021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198499021">(May 22 2020 at 21:51)</a>:</h4>
<p>What about</p>
<div class="codehilite"><pre><span></span><code>error: `impl` item signature doesn&#39;t match `trait` item signature
  --&gt; $DIR/trait-param-without-lifetime-constraint.rs:14:5
   |
LL |     fn get_relation(&amp;self) -&gt; To;
   |     ----------------------------- expected `fn(&amp;Article) -&gt; &amp;ProofReader`
...
LL |     fn get_relation(&amp;self) -&gt; &amp;ProofReader {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&amp;Article) -&gt; &amp;ProofReader`
   |
   = note: expected `fn(&amp;Article) -&gt; &amp;ProofReader`
              found `fn(&amp;Article) -&gt; &amp;ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
   |
LL |     fn get_relation(&amp;self) -&gt; To;
   |                               -- consider borrowing this type parameter in the trait
</code></pre></div>



<a name="198499094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198499094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198499094">(May 22 2020 at 21:52)</a>:</h4>
<p>definitely an improvement</p>



<a name="198499109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198499109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198499109">(May 22 2020 at 21:52)</a>:</h4>
<p>I guess if you wanted to land that for now I'd r+</p>



<a name="198499117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198499117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198499117">(May 22 2020 at 21:52)</a>:</h4>
<p>and we can see what happens to the bug reports ;)</p>



<a name="198499149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/impl%20signature%20mismatch%20errors%20PR%20%2367460/near/198499149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/impl.20signature.20mismatch.20errors.20PR.20.2367460.html#198499149">(May 22 2020 at 21:53)</a>:</h4>
<p>I'm pretty happy with the progress we've made over the last few years, there's still more to fix <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>